package utilities;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
//parsing data based on index of byte array
//if 2 additional bytes: move the indexes forward
public class DataParsing {
	
	public static String getCarrierCD(byte[] data){
		return new String(data,28,3).trim();
	}
	
	public static String getOriginCityCD(byte[] data){
		//return new String(data,138,9);
		return new String(data,128,9);
	}
	
	public static String getAWB_NBR(byte[] data){
		//return new String(data,35,9).trim();
		//return new String(data,33,9).trim();
		return new String(data,39,9).trim();
	}
	
	public static String getAWBDate(byte[] data){
		//return new String(data,43,2)+ "-" + new String(data,45,2)+ "-" + new String(data,47,3);
		//return new String(data,43,2)+ new String(data,45,2)+ new String(data,47,3);
		return new String(data,42,2)+ "-" + new String(data,44,2)+ "-" + new String(data,46,2);
	}
	
	public static String getAWBTime(byte[] data){
		//return new String(data,52,2).trim() + ":" + new String(data,54,2).trim();
		//return new String(data,52,5).trim();
		return new String(data,49,2).trim() + ":" + new String(data,51,2).trim();
	}
	
	/*public static String getMigrateDate(){
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd_hh-mm-ss"); //hh:mm:ss cause error in Windows
	    return df.format(new Date()); 
	}*/
	
	public static String getCADContent(byte[] data){
		return new String(data).trim();
	}
	
	
}
